<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
    <hr>
    <news></news>
  </div>

  <template id="tpl">
    <div>
      <h2>我是home页</h2>
      <common-head :title="homeTitle" sub_title="我是二级标题"></common-head>
    </div>
  </template>

  <template id="tpl2">
    <div>
      <h2>我是news页</h2>
      <common-head title="我是news的标题"></common-head>
    </div>
  </template>

  <script src="./vue.js"></script>
  <script>
    const CommonHead = {
      template:`
        <div>
          公共的头部组件
          <h3>{{title}}</h3>
          <h4>{{sub_title}}</h4>
        </div>
      `,
      // properties  怎么接收
      props: ['title', 'sub_title']
    }

    const Home = {
      template:"#tpl",
      components:{
        CommonHead
      },
      data(){
        return {
          homeTitle:'我是home的标题，我是data中定义的'
        }
      }
    }
    Vue.component('Home', Home)
    const News = {
      template:"#tpl2",
      components:{
        CommonHead
      }
    }
    Vue.component('News', News)
    const vm = new Vue({
      el:'#app'
    })
  </script>
</body>
</html>